package com.cmcc.driver.ui.profile

import android.os.Bundle
import android.webkit.WebSettings
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.databinding.DataBindingUtil
import com.alibaba.android.arouter.facade.annotation.Route
import com.cmcc.driver.R
import com.cmcc.driver.config.AppConfig
import com.cmcc.driver.config.DriverPath
import com.cmcc.driver.databinding.ActivityArticlesOfLawBinding
import com.cmcc.driver.ui.base.BasicActivity
import com.cmcc.shared.utils.L

/**
 * Author: jiangxin
 * Date: 2019/11/6
 * Description:
 */
@Route(path = DriverPath.ARTICLES_OF_LAW)
class ArticleOfLawActivity : BasicActivity() {

    override fun initialize(savedInstanceState: Bundle?) {
        val binding = DataBindingUtil.setContentView<ActivityArticlesOfLawBinding>(this, R.layout.activity_articles_of_law)
        binding.appbar.title.text = getString(R.string.article_of_law_title)
        binding.appbar.toolbar.setNavigationOnClickListener { finish() }

        val webSettings = binding.articlesOfLaw.settings
        webSettings.javaScriptEnabled = true
        webSettings.javaScriptCanOpenWindowsAutomatically = true
        webSettings.allowFileAccess = true// 设置允许访问文件数据
        webSettings.setSupportZoom(true)//支持缩放
        webSettings.javaScriptCanOpenWindowsAutomatically = true
        webSettings.cacheMode = WebSettings.LOAD_NO_CACHE
        webSettings.domStorageEnabled = true
        webSettings.databaseEnabled = true

        binding.articlesOfLaw.webViewClient = webClient
        binding.articlesOfLaw.loadUrl(AppConfig.APP_ARTICLE_LAW)
    }

    private val webClient = object : WebViewClient() {
        override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
            L.d("loading------articlesOfLaw", url!!)
            return false
        }
    }


}